[DRAFT] Add MinimalGenerics
and allow users to set a GenericsStrategy
#879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We currently support wo strategies for generics:
DefaultGenerics
andNoGenerics
.The former is enabled by default, but was responsible for most of the bugs found in Kryo 5 and incurs some performance overhead. Users can currently opt-out of generics optimization by setting
Kryo.setOptimizeGenerics(false)
. Internally, this flag sets the generic strategy toNoGenerics
.This PR introduces a third strategy called
MinimalGenerics
that only processes generic type information, but does not attempt to resolve type variables. This makes sense because the type variable logic is quite involved, still has edge-case issues (e.g. #864), and causes most of the performance overhead related to generics handling.The new strategy is safer and should theoretically be faster than disabling generics optimizations altogether, because concrete generic types can still be resolved.
CollectionSerializer
andMapSerializer
should especially benefit from this.TODO